#!/usr/bin/python
# -*- coding: utf-8 -*-

import os

from django.shortcuts import render_to_response

from google.appengine.api import users

def home(request):
    return render_response(request, "home.html")

def render_response(request, template, parameters=None):
    if parameters is None:
        parameters = {}
    parameters["user"] = users.GetCurrentUser()
    parameters["sign_out"] = users.CreateLogoutURL('/')
    parameters["is_admin"] = (users.IsCurrentUserAdmin() and
                              "Dev" in os.getenv("SERVER_SOFTWARE"))
    if parameters["user"] is None:
        parameters["sign_in"] = users.CreateLoginURL(request.path)
    return render_to_response(template, parameters)
